#include<iostream>
#include<unordered_map>
using namespace std;


class Solution {
public:
    bool isAnagram(string s, string t) {
        unordered_map<char, int> hashS;
        unordered_map<char, int> hashT;
        for (auto e : s) {
            hashS[e]++;
        }
        for (auto e : t) {
            hashT[e]++;
        }
        if (hashS.size() != hashT.size()) {
            return false;
        }
        for (auto& e : hashS) {
            if (e.second != hashT[e.first]) {
                return false;
            }
        }
        return true;
    }
};